<?php

	include_once "../../../config.inc.php";
	
	$connection = pg_connect("host=".W." port=".V." dbname=".Z." user=".Y." password=".X) or die ("Falló la conexion");
	 
	$app = $_GET['app'];
	$usr = $_GET['usr'];
	$count = $_GET['count'];
	
	$query = "SELECT B.* FROM APPLICATIONS A, SECTIONS B WHERE A.APP_ID = B.APP_ID AND A.APP_ID = ".$app;			
	$select = pg_query($connection, $query);

	$upTag = '	<table width="686" border="0" align="center" id="menuElement'.$count.'">
  <tr>
    <td width="141"><input type="text" name="optionName[]" id="optionName[]" class="inputOptionMenu" placeholder="Nombre de Opci&oacute;n"></td>
    <td width="262">/ Indique Acción:
       <select name="actionOptions[]" id="actionOptions[]" style="border-radius: 15px;
width:150px;"> <option value="0"> Seleccione -</option> <option value="1"> Ir a Sección </option> <option value="2"> No hacer nada </option>
    </select></td>     <td width="201">/ Ir a: 
      <select name="sectionsPath[]" id="sectionsPath[]" style="border-radius: 15px;
width:150px;"> <option value="0"> Seleccione -</option>
';

	$bottomTag = '    </select></td>
    <td width="27"><img src="../imagenes/removeMenuOption.png" onClick="removeElement('.$count.')"/></td>
  </tr>
</table>
';

	$middleTag = '';
	
		while ($row = pg_fetch_row($select)) {
			set_time_limit(0);			
			$middleTag = $middleTag. '<option value="'.$row[2].'"> '.$row[2].'</option>';									
		}
	echo $upTag.$middleTag.$bottomTag;
?>